Repository navigation
Conversation
…reconciliation Add a pure statement reconciliation module with an effective-dated fee schedule (broker-assisted fee, SEC Section 31, FINRA TAF) and a valuation basis difference check (tolerance max($0.10, 0.1% of market value)). Keep balance long_stock_value as a distinct collector fact and let the snapshot builder persist it only behind an explicit opt-in, because the QRS console schema rejects extra Firstrade balance keys today.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
…checks - Correct the FINRA TAF schedule per SR-FINRA-2026-020: 2027 and 2028 stay at 0.000195/share (max 9.79), 2029 is 0.000232 (max 11.61), then 2030 and 2031 rows; cite SR-FINRA-2026-020 and -021 in the header. - Add verified_through to the fee schedule; lookups after that date are unsupported because the SEC FY2027 Section 31 rate is not published. - Treat the CSV Date column as the trade date (checked against EXEC TIME and S/D); a settlement-dated row is unsupported instead of misrated. - Reject non-positive quantity or price with boundary tests. - Cap the valuation tolerance at 25.00, cross-check position quantities and stop an empty positions list from passing as a basis difference.
A conflict between the top-level and result long_stock_value now withholds that auxiliary value and sets coverage long_stock_value_ambiguous, so cash, equity and positions are still collected. The opt-in snapshot option reports long_stock_value_ambiguous distinctly. A cash_balance conflict still fails closed.
Contributor
Author
Pigbibi
deleted the
feat/statement-fee-split-valuation-basis-20261101
branch
November 18, 2026 15:28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AI assistance
Grok Bot (an AI agent working for the repository owner) wrote the code, tests and documentation in this PR. It was not merged or deployed by the agent; human review is pending.
What changed
Problem: two Firstrade reconciliation differences (August 19.96 and total assets 0.06) were reported as unexplained. They come from the broker-assisted order fee (19.95) plus SEC Section 31 / FINRA TAF regulatory fees on margin-sellout sells, and from a price-basis difference between the balance API
long_stock_valueand summed position market values.Behaviour after this PR:
BROKER/DEALER ORDER(includingMARGIN SELLOUT) are split into broker-assisted fee, SEC fee and TAF. Unrounded fees are summed and rounded up to the cent with a 0.01 minimum; a residual within +/-0.01 isexplained.verified_through(2026-11-01) makes any later trade dateunsupported, because the SEC FY2027 Section 31 rate is not published.Datecolumn is treated as the trade date (checked againstEXEC TIMEandS/D; the 8/28 IBIT row settles 8/31). Non-positive quantity or price isunsupported.valuation_basis_differencewith tolerance min(max(0.10, 0.1% of market value), 25.00), an optional position-quantity cross-check, andunexplainedfor an empty positions list with a non-zero balance.long_stock_valueas its own fact; a conflicting value is flagged (long_stock_value_ambiguous) instead of failing the whole collection. The snapshot persists it only behind an explicit opt-in.How verified
pytest tests/test_statement_reconciliation.py tests/test_account_facts_readonly.py tests/test_account_facts_publisher.py: 122 passed.ruff checkpasses.quant_platform_kit, identical on the base commit (checked withgit stash).